<!DOCTYPE html>

<html>

<head>
  <title>Beego</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

</head>
<style>
  input {
    margin-top: 5px;
    border-radius: 2px;
  }

  form {
    border-radius: 10px;
  }

  form>input {
    border: none;
  }

  .button {
    background-color: rgb(63, 79, 222);
    padding: 5px;
    border: none;
  }
</style>

<body>
  <form style="background-image: linear-gradient(to top, #d03055 0%, #c7b6dc 100%); 
     height: 270px; width: 250px; color: white; text-align:center;
    margin: 0 auto; padding: 5px;">
    <h3> 新用户注册</h3>
    <label for="sn">学号:</label>
    <input type="text" name="" value="" id="sn">
    <br>
    <label for="pswd">密码:</label>
    <input type="password" name="" value="" id="pswd">
    <br>
    <label for="sn">性别:</label>
    <input type="text" name="" value="" id="sex">
    <br>
    <label for="sn">姓名:</label>
    <input type="text" name="" value="" id="name">
    <br>
    <label for="sn">电话:</label>
    <input type="text" name="" value="" id="tel">
    <br>
    <label for="sn">邮件:</label>
    <input type="text" name="" value="" id="email">
    <br>
    <label for="sn">备注:</label>
    <input type="text" name="" value="" id="comments">
    <br>

    <input onclick="register()" value="确定注册" class="button" type="button"></input>
    <br>
  </form>

</body>
<script>

  function register() {
    var userinfo = new Object();
    userinfo.Sn = document.getElementById("sn").value;
    userinfo.Pswd = document.getElementById("pswd").value;
    userinfo.Name = document.getElementById("name").value;
    userinfo.Sex = document.getElementById("sex").value;
    userinfo.Tel = document.getElementById("tel").value;
    userinfo.Email = document.getElementById("email").value;
    userinfo.Comments = document.getElementById("comments").value;

    fetch("/doRegister", {
      method: "post",
      body: JSON.stringify(userinfo)
    })
      .then(resp => resp.text())//解析
      .then(data => { //后续业务处理}
      alert(data)
      }
      )
  }




</script>

</html>